BreadthFirstScan
BreadthFirstScan[g,s,{event1->f1,event2->f2,…}] performs a breadth-first scan (bfs) of the graph g starting at the vertex s and evaluates fi whenever "eventi" occurs.
BreadthFirstScan[g,{event1->f1,event2->f2,…}] performs a breadth-first scan of the whole graph g.
BreadthFirstScan[{v->w,…},…] uses rules v->w to specify the graph g.
Please visit the official Wolfram Language Reference for more details and examples on core symbols.